package com.example.ex02login;



import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class LoginActivity extends Activity implements OnClickListener {
	
	 private final String EXTRA_LOGIN=null;
	 private EditText edit_login;  
     private Editor editor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        Button btconnexion = (Button) findViewById(R.id.connect);
        btconnexion.setOnClickListener(this);
        
          
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.login, menu);
        return true;
    }


	@Override
	public void onClick(View v) {
		switch(v.getId()){
    	case R.id.connect:
    	Intent intents = new Intent(this,ListviewActivity.class);
    	setResult(RESULT_OK, intents);
    	edit_login = (EditText) findViewById(R.id.editlogin);
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
         editor = pref.edit();
         editor.putString("edit_login",edit_login.getText().toString() );
     	 editor.commit();
         
     	
    	
    	startActivity(intents);
    	finish();
    	break;
    	}

		
	}
    
}
